let id;

function getId() {
    const url = document.URL
    const val = url.split('?')[1]
    const par = val.split('id=')[1]
    id = par.split('&')[0]
}

function showArticle(id) {
    const url = root + '/article/' + id
    $.get(url, function(result) {
        const data = result.data
        $('#article_title').html(data.articleTitle)
        $('#article_date').html(data.createDate)
        const converter = new showdown.Converter();
        $('#article_text').html(converter.makeHtml(data.articleContext))
        $('#diggnum').html(data.likeCounter)
    })
}

getId()
showArticle(id)

function good() {
    const url = root + '/article/' + id + '/like'
    $.get(url, function(result) {
        if (result.data) {
            let count = parseInt($('#diggnum').html())
            $('#diggnum').html(count + 1)
        } else {
            alert('不知名错误，请联系开发者')
        }
    })
}